package com.ujoin.action.user;

import org.json.simple.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import com.ujoin.util.ActionEnhanced;
import com.ujoin.service.UserService;

@SuppressWarnings("serial")
public class CheckExistAction extends ActionEnhanced {

	private int age;
	private String json;

	public String getJson() {
		return json;
	}

	public void setJson(String json) {
		this.json = json;
	}

	public int getAge() {
		return age;
	}

	public void setAge(int age) {
		this.age = age;
	}

	@Autowired
	private UserService userService;
	
	@Override
	public void validate() {
		if (this.getFieldErrors().isEmpty())
			return;
		JSONObject jsonOb = new JSONObject();
		jsonOb.put("result", "OK");
		jsonOb.put("Message",  this.getFieldErrors());
		this.json = jsonOb.toString();
		System.out.println("validate");
		return;
	};

	@Override
	public String execute() throws Exception {
		// TODO Auto-generated method stub
		this.setJson(userService.findAll());
		// return super.execute();
		return SUCCESS;
	}

}
